use "${clean}analysis.dta", clear

keep if north == 1
keep if year < 1900

//standardizing variables
egen birth_county_surban = std(birth_county_urban_percent)
egen birth_county_srugged = std(birth_county_ruggedness)
egen birth_county_spostoffice = std(birth_county_postoffice_area)
egen sborn = std(born)

// creating a variable to keep the sample constant
cap drop sample
gen sample = 1
foreach var of varlist $county_bcontrols $life_controls {
	replace sample = . if `var' == .
}
keep if sample == 1

drop if partyid == 2 // dropping third party

// dropping WHIGS
replace partyid = . if party_name == "Whig"
replace partyid = 1 if bioguide == "B000376"
replace partyid = 1 if bioguide == "S000261"
replace partyid = 1 if bioguide == "S000801"


// collapsing
collapse (count) numspeech = singular, by(year partyid)


// graphing
replace year = year + 0.4 if partyid == 1
replace year = year - 0.4 if partyid == 0 

twoway ///
	(scatteri 200 1861 200 1865, fcolor("${orange}") finten(inten20) recast(area)) ///
	(bar numspeech year if partyid == 1, fcolor("${red}") lcolor(gs1) barw(0.8)) ///
	(bar numspeech year if partyid == 0, fcolor("${blue}") lcolor(gs1) barw(0.8)) ///
	, legend(ring(0) row(1) order(3 "Democrats" 2 "Whigs / Republicans") pos(1) ) ///
	xlab(1852(4)1900) ///
	ylab(0(25)200, glcolor(gs15)) ///
	ytitle("Number of Statements", size(medsmall)) xtitle(Year, size(medsmall) ) ///
	text(190 1863 "Civil", size(medsmall)) ///
	text(182.5 1863 "War", size(medsmall)) ///
	scheme(lean2) 	
graph export "${output}FigS8_histogram_northerners.pdf", as(pdf) replace
